/**
 * 
 */
package com.qf.apps;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.qf.apps.vo.InformationForm;
import com.qf.domain.Information;
import com.qf.service.InformationService;

/**
 * @author 123
 * 
 */
public class InformationController extends SimpleFormController {
	private InformationService informationService;

	protected Object formBackingObject(HttpServletRequest request)
			throws Exception {
//		System.out.println("formBackingObject");
		return new InformationForm();
	}

	protected ModelAndView onSubmit(HttpServletRequest request,
			HttpServletResponse response, Object command, BindException errors)
			throws Exception {
		Map map = new HashMap();
		InformationForm informationForm = (InformationForm) command;
		Information information = informationForm.getInformation();
		System.out.println(information.getContent());
		Integer id = this.informationService.addInformation(information);
		String Content=information.getContent();
		map.put("id", id);
		map.put("Content", Content);
		return new ModelAndView(getSuccessView(),"map",map);
	}

	public InformationService getInformationService() {
		return informationService;
	}

	public void setInformationService(InformationService informationService) {
		this.informationService = informationService;
	}
}
